package com.ilovepostcard.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.ilovepostcard.HomeActivity;
import com.ilovepostcard.LoginActivity;
import com.ilovepostcard.R;
import com.ilovepostcard.utils.ThirdPartyLoginUtil;
import com.ilovepostcard.view.PostcardMenuItem.OnMenuClickListener;

public class PostcardRegisterMenu extends LinearLayout {

    public PostcardRegisterMenu(Context context, AttributeSet attrs) {
        super(context, attrs);
        inflate();
    }

    public PostcardRegisterMenu(Context context) {
        super(context);
        inflate();
    }

    private void inflate() {
        View view = View.inflate(getContext(), R.layout.postcard_register_menu, this);
        ((PostcardMenuItem)view.findViewById(R.id.menu_sina)).setOnMenuClickListener(new OnMenuClickListener() {
            
            @Override
            public void onClickMenu() {
                Activity activity = ((Activity)getContext());
                activity.setResult(HomeActivity.RESULT_CODE_SINA);
                activity.finish();
//                ThirdPartyLoginUtil.sinaLogin((Activity)getContext());
            }
        });
        
        ((PostcardMenuItem)view.findViewById(R.id.menu_qq)).setOnMenuClickListener(new OnMenuClickListener() {
            
            @Override
            public void onClickMenu() {
                Activity activity = ((Activity)getContext());
                activity.setResult(HomeActivity.RESULT_CODE_TENCENT);
                activity.finish();
//                ThirdPartyLoginUtil.tencentLogin((Activity)getContext());
            }
        });
        
        ((PostcardMenuItem)view.findViewById(R.id.menu_postcard)).setOnMenuClickListener(new OnMenuClickListener() {
            
            @Override
            public void onClickMenu() {
                Intent intent = new Intent(getContext(), LoginActivity.class);
                getContext().startActivity(intent);
                ((Activity)getContext()).finish();
            }
        });
    }
}
